<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>07</title>
</head>
<body>
<table border="1">
  <caption>个狗信息</caption>
  <tr>
    <td>照骗</td>
    <td id="head_td"></td>
  </tr>
  <tr>
    <td>犬种</td>
    <td id="name_td"></td>
  </tr>
  <tr>
    <td>年龄</td>
    <td id="age_td"></td>
  </tr>
  <tr>
    <td>同类</td>
    <td id="friend_td"></td>
  </tr>
</table>
<input type="button" value="请求数据" onclick="f()">

<script>
  function f() {
    //准备数据
    let dog = {url:"1.jpg",name:"姜桑",age:36,friend:["傻狗","丑狗","脏狗"]}
    //把对象中的数据展示到页面中
    let name_td = document.querySelector("#name_td")
    name_td.innerText = dog.name
    let age_td = document.querySelector("#age_td")
    age_td.innerText = dog.age
    //创建图片，把对象中的图片路径设置给图片标签，并添加到td里面
    let img = document.createElement("img")
    img.src = dog.url
    img.width = 100;
    head_td.append(img)
    //创建ul和li，添加到td中
    let ul = document.createElement("ul")
    //遍历数组
    for (let name of dog.friend) {
      //创建图片
      let img = document.createElement("img")
      img.src = "5.jpg"
      img.width = 100
      //创建li
      let li = document.createElement("li")
      li.innerText = name
      li.append(img)
      //把li装到ul里
      ul.append(li)
      //把ul装进到li
      friend_td.append(ul)
    }
  }
</script>

</body>
</html>